<tc_include file="Public:header" />
  <title>意见反馈</title>
</head>
<body ontouchstart class="white-bg">
<div class="container">
	<div class="weui-tab__panel">
		<div class="weui-cells weui-cells_form weui-textarea-box">
		    <div class="weui-cell">
		        <div class="weui-cell__bd">
		            <textarea class="weui-textarea" id="feedback" placeholder="请填写您的意见反馈，我们将尽力改善服务，谢谢！" rows="6"></textarea>
		            
		        </div>
		    </div>
		</div>
	</div>
</div>
<!--foot button-->
<div class="weui-footer weui-footer_fixed-bottom">
	<a href="javascript:;" onclick="add()" class="weui-btn weui-btn_warn">确认提交</a>
</div>
<!--BEGIN toast-->
<div id="toast" style="display: none;">
	<div class="weui-mask_transparent"></div>
	<div class="weui-toast">
		<p class="weui-toast__content" id="content"></p>
	</div>
</div>
<!--end toast-->
<!--foot button end-->
<script src="__PUBLIC__/home/js/zepto.min.js"></script>
<script src="__PUBLIC__/home/js/weui.min.js"></script>
<script>
    var $toast = $('#toast');
	function add(){
        var feedback = $("#feedback").val();
        if (feedback=='') {
            errorPrompt('反馈内容不能为空');
            return false;
        }
        $.ajax({
            url:"{:U('Feedback/add_post')}",
            type:'put',
            dataType:'json',
            data:{
                'userName':"<php>echo cookie('user_name')</php>",
                'feedBack':feedback
            },
            success:function(data){
                console.log(data);
				if (data.success){
                    errorPrompt("感谢您的反馈");
					setTimeout(function(){
                        location.href="{:U('information/index')}";
                    },2000)
				}else{
                    errorPrompt("反馈失败");
				}
            }
        })
	}

    function errorPrompt(explain){
        $("#content").html(explain);
        $toast.fadeIn(100);
        setTimeout(function () {
            $toast.fadeOut(100);
        }, 2000);
    }
</script>
</body>
</html>
